package com.lucky.qa.controller;


import com.lucky.qa.pojo.user;
import com.lucky.qa.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 * Created by sl982 on 2017-03-21.
 */
@Controller
@RequestMapping("/sysUserController")
public class UserController {
    @Resource
    private UserService sysUserService;

    @RequestMapping("/showUserToJspById/{userId}")
    public String showUser(Model model, @PathVariable("userId") int userId){
        user user = this.sysUserService.getById(userId);
        model.addAttribute("user", user);
        return "showUser";
    }

    @RequestMapping("/showUserToJSONById/{userId}")
    @ResponseBody
    public user showUser(@PathVariable("userId") int userId){
        user user = sysUserService.getById(userId);
        return user;
    }

    @RequestMapping(value = "/Register",method = RequestMethod.GET)
    public String register(){
        return "/user/register";
    }

    @RequestMapping(value = "/Register",method = RequestMethod.POST)
    public void registerSave(){

    }
}